<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>WebGL以无符号字节传递颜色的原理 | 小魏的博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
    <meta name="keywords" content="Vker,Vker's Blog">
  
  <meta name="description" content="这个算属于 WebGL 进阶吧, 因为这个属于优化, 运行效率, 如果你不了解 WebGL 的基本知识,你可以到这里先学习基础知识.我会在下面放上几个比较好的学习链接.  涉及到的知识点如下   编程里面的位运算 中的(&amp;amp;)这个符号的运算法则 WebGL vertexAttribPointer 这个接口中的 normalized 到底是怎么做的归一化 给 WebGL 传递一个值 为什么我们">
<meta name="keywords" content="js,WebGL,前端">
<meta property="og:type" content="article">
<meta property="og:title" content="WebGL以无符号字节传递颜色的原理">
<meta property="og:url" content="https://leng521.top/posts/af81a0c5/index.html">
<meta property="og:site_name" content="小魏的博客">
<meta property="og:description" content="这个算属于 WebGL 进阶吧, 因为这个属于优化, 运行效率, 如果你不了解 WebGL 的基本知识,你可以到这里先学习基础知识.我会在下面放上几个比较好的学习链接.  涉及到的知识点如下   编程里面的位运算 中的(&amp;amp;)这个符号的运算法则 WebGL vertexAttribPointer 这个接口中的 normalized 到底是怎么做的归一化 给 WebGL 传递一个值 为什么我们">
<meta property="og:locale" content="default">
<meta property="og:image" content="https://leng521.top/posts/af81a0c5/38F64298.jpg">
<meta property="og:image" content="https://leng521.top/posts/af81a0c5/1231.png">
<meta property="og:image" content="https://leng521.top/posts/af81a0c5/39532F4A.jpg">
<meta property="og:updated_time" content="2019-08-14T03:22:53.967Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="WebGL以无符号字节传递颜色的原理">
<meta name="twitter:description" content="这个算属于 WebGL 进阶吧, 因为这个属于优化, 运行效率, 如果你不了解 WebGL 的基本知识,你可以到这里先学习基础知识.我会在下面放上几个比较好的学习链接.  涉及到的知识点如下   编程里面的位运算 中的(&amp;amp;)这个符号的运算法则 WebGL vertexAttribPointer 这个接口中的 normalized 到底是怎么做的归一化 给 WebGL 传递一个值 为什么我们">
<meta name="twitter:image" content="https://leng521.top/posts/af81a0c5/38F64298.jpg">
  
  
    <link rel="icon" href="/head.jpg">
  
  <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css">
  <script src="/js/pace.min.js"></script>
  

  
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?2eaff0c5326867354b0d3469d507d209";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>

  

</head>
</html>
<body>
  <div id="container">
      <header id="header">
    <div id="banner"></div>
    <div id="header-outer">
        <div id="header-menu" class="header-menu-pos animated">
            <div class="header-menu-container">
                <a href="/" class="left">
                    <span class="site-title">Vker&#39;s Blog</span>
                </a>
                <nav id="header-menu-nav" class="right">
                    
                    <a  href="/">
                        <i class="fa fa-home"></i>
                        <span>Home</span>
                    </a>
                    
                    <a  href="/archives">
                        <i class="fa fa-archive"></i>
                        <span>Archives</span>
                    </a>
                    
                    <a  href="/about">
                        <i class="fa fa-user"></i>
                        <span>About</span>
                    </a>
                    
                </nav>
                <a class="mobile-header-menu-button">
                    <i class="fa fa-bars"></i>
                </a>
            </div>
        </div>
        <div id="header-row">
            <div id="logo">
                <a href="/">
                    <img src="/head.jpg" alt="logo">
                </a>
            </div>
            <div class="header-info">
                <div id="header-title">
                    
                    <h2>
                        Vker&#39;s Blog
                    </h2>
                    
                </div>
                <div id="header-description">
                    
                    <h3>
                        一个专注 游戏研发 的技术博客
                    </h3>
                    
                </div>
            </div>
            <nav class="header-nav">
                <div class="social">
                    
                        <a title="Vker" target="_blank" href="//leng521.top">
                            <i class="fa fa-home fa-2x"></i></a>
                    
                        <a title="Github" target="_blank" href="//github.com">
                            <i class="fa fa-github fa-2x"></i></a>
                    
                        <a title="Weibo" target="_blank" href="//weibo.com">
                            <i class="fa fa-weibo fa-2x"></i></a>
                    
                        <a title="Twitter" target="_blank" href="//twitter.com">
                            <i class="fa fa-twitter fa-2x"></i></a>
                    
                </div>
            </nav>
        </div>
    </div>
</header>
      <div class="outer">
        <section id="main" class="body-wrap"><article id="post-WebGL以无符号字节传递颜色的原理" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 class="post-title" itemprop="name">
      WebGL以无符号字节传递颜色的原理
    </h1>
    <div class="post-title-bar">
      <ul>
          
              <li>
                  <i class="fa fa-book"></i>
                  
                      <a href="/categories/前端/">前端</a>
                  
                      <a href="/categories/WebGL/">WebGL</a>
                  
              </li>
          
        <li>
          <i class="fa fa-calendar"></i>  2019-06-14
        </li>
        <li>
          <i class="fa fa-eye"></i>
          <span id="busuanzi_value_page_pv"></span>
        </li>
      </ul>
    </div>
  

          
      </header>
    
    <div class="article-entry post-content" itemprop="articleBody">
      
            
            <p>这个算属于 WebGL 进阶吧, 因为这个属于优化, 运行效率, 如果你不了解 WebGL 的基本知识,你可以到这里先学习基础知识.<br>我会在下面放上几个比较好的学习链接.</p>
<blockquote>
<p>涉及到的知识点如下</p>
</blockquote>
<ol>
<li>编程里面的位运算 中的(&amp;)这个符号的运算法则</li>
<li>WebGL vertexAttribPointer 这个接口中的 normalized 到底是怎么做的归一化</li>
<li>给 WebGL 传递一个值 为什么我们能拿到四个值(用于优化每次传递数据的尺寸)</li>
</ol>
<a id="more"></a>
<p>如果先了解写这篇文章的意图话可以直接跳转到意图开始看. 啊哈</p>
<h1 id="意图"><a href="#意图" class="headerlink" title="意图"></a>意图</h1><p>在看一些引擎源码的时候总是在给 GUP 传递颜色的时候会看类似下面这样的代码. 下面我写一个伪代码.</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 着色器伪代码</span></span><br><span class="line"><span class="keyword">let</span> vs = <span class="string">`</span></span><br><span class="line"><span class="string">attribute vec2 a_position;</span></span><br><span class="line"><span class="string">attribute vec2 a_texCoord;</span></span><br><span class="line"><span class="string">attribute vec4 a_tint; 😄😄😄</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">varying vec2 v_texCoord;</span></span><br><span class="line"><span class="string">varying vec4 v_tint;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">void main() &#123;</span></span><br><span class="line"><span class="string">	gl_Position = vec4(a_position, 1.0, 1.0);</span></span><br><span class="line"><span class="string">	v_tint = a_tint;</span></span><br><span class="line"><span class="string">	v_texCoord = a_texCoord;</span></span><br><span class="line"><span class="string">&#125;</span></span><br><span class="line"><span class="string">`</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> fs = <span class="string">`</span></span><br><span class="line"><span class="string">precision mediump float;</span></span><br><span class="line"><span class="string">uniform sampler2D u_texture;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">varying vec2 v_TexCoord;</span></span><br><span class="line"><span class="string">varying vec4 v_tint;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">void main() &#123;</span></span><br><span class="line"><span class="string">	gl_FragColor = texture2D(u_texture, v_TexCoord) * v_tint;</span></span><br><span class="line"><span class="string">&#125;</span></span><br><span class="line"><span class="string">`</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> arrayBuffer = <span class="keyword">new</span> <span class="built_in">ArrayBuffer</span>(<span class="number">5</span>*<span class="number">4</span>);</span><br><span class="line"><span class="keyword">let</span> float32Array = <span class="keyword">new</span> <span class="built_in">Float32Array</span>(arrayBuffer);</span><br><span class="line"><span class="keyword">let</span> uint32Array = <span class="keyword">new</span> <span class="built_in">Uint32Array</span>(arrayBuffer);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 传递顶点数据</span></span><br><span class="line">float32Buffer[<span class="number">0</span>] = <span class="number">1</span>;</span><br><span class="line">float32Buffer[<span class="number">1</span>] = <span class="number">0</span>;</span><br><span class="line"><span class="comment">// 传递uv坐标</span></span><br><span class="line">float32Buffer[<span class="number">3</span>] = <span class="number">0</span>;</span><br><span class="line">float32Buffer[<span class="number">4</span>] = <span class="number">0</span>;</span><br><span class="line"><span class="comment">// 传递颜色</span></span><br><span class="line"><span class="keyword">let</span> a = &#123;</span><br><span class="line">    tint: <span class="number">0x00ff00</span>,</span><br><span class="line">    alpha: <span class="number">1</span>,</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> b = (a.tint &gt;&gt; <span class="number">16</span>) + (a.tint &amp; <span class="number">0xff00</span>) + ((a.tint &amp; <span class="number">0xff</span>) &lt;&lt; <span class="number">16</span>) + (a.alpha * <span class="number">255</span> &lt;&lt; <span class="number">24</span>); 😄😄😄</span><br><span class="line">uint32Array[<span class="number">5</span>] = b; 😄😄😄</span><br><span class="line"><span class="comment">// ... 可能还会有其他的数据传递这个都得看他们是怎么处理了,</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 指定顶点属性 和 UV 属性我就不写了.</span></span><br><span class="line">[...]</span><br><span class="line"></span><br><span class="line"><span class="comment">// 指定 颜色 属性</span></span><br><span class="line">gl.enableVertexAttribArray(<span class="number">2</span>);</span><br><span class="line"><span class="comment">// void gl.vertexAttribPointer(index, size, type, normalized, stride, offset);</span></span><br><span class="line">gl.vertexAttribPointer(<span class="number">2</span>, <span class="number">4</span>, gl.UNSIGNED_BYTE, <span class="literal">true</span>, <span class="number">5</span>*<span class="number">4</span>, <span class="number">4</span>*<span class="number">4</span>); 😄😄😄</span><br></pre></td></tr></table></figure>
<p>我只会解释 在代码后面 带 😄😄😄 这个标识的代码.我相信其他的代码,聪明的你自己看懂这个看随意😄.</p>
<p>总会出现,在传递的颜色的时候,使用 <code>Uint32Array</code> 这种类型,其他的依旧是 <code>Float32Array</code>, 而且乍一看,还带了一堆位运算.<br><img src="/posts/af81a0c5/38F64298.jpg"><br>普通人表示看不懂. 有点强,这个三行代码.</p>
<p>于是乎这篇文章诞生了.</p>
<h1 id="解决疑惑"><a href="#解决疑惑" class="headerlink" title="解决疑惑"></a>解决疑惑</h1><p>首先你要做的就是,自己变成电脑,去执行代码.</p>
<h2 id="那一堆位运算到底做了啥"><a href="#那一堆位运算到底做了啥" class="headerlink" title="那一堆位运算到底做了啥"></a>那一堆位运算到底做了啥</h2><p><code>&amp;</code> 这个运算符 就是</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1</span> &amp; <span class="number">1</span> =&gt; <span class="number">1</span></span><br><span class="line"></span><br><span class="line"><span class="number">1</span> &amp; <span class="number">0</span> =&gt; <span class="number">0</span></span><br><span class="line"></span><br><span class="line"><span class="number">0</span> &amp; <span class="number">0</span> =&gt; <span class="number">0</span></span><br></pre></td></tr></table></figure>
<blockquote>
<blockquote>
<p>(a.tint &gt;&gt; 16) + (a.tint &amp; 0xff00) + ((a.tint &amp; 0xff) &lt;&lt; 16) + (a.alpha * 255 &lt;&lt; 24)</p>
</blockquote>
</blockquote>
<p>它既然是位运算,那我们就把他转成二进制看,毕竟自己依然是电脑了,这个才是你的母语.</p>
<img src="/posts/af81a0c5/1231.png">
<p>好经过上面的推算得出最终的结果了. 就是 11111111 00000000 11111111 00000000</p>
<h2 id="有Uint32Array-处理一下我的数据"><a href="#有Uint32Array-处理一下我的数据" class="headerlink" title="有Uint32Array 处理一下我的数据"></a>有Uint32Array 处理一下我的数据</h2><p>因为的数据可能是负数 这个是不行的.<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">uint32Array[<span class="number">5</span>] = b; 😄😄😄</span><br></pre></td></tr></table></figure></p>
<p>一个负数就变成正数了.</p>
<p>至于他是怎么变的, 你可以找度娘 问她 编程里的大小端是什么东西.</p>
<h2 id="指定这些数据怎么用"><a href="#指定这些数据怎么用" class="headerlink" title="指定这些数据怎么用"></a>指定这些数据怎么用</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// void gl.vertexAttribPointer(index, size, type, normalized, stride, offset);</span></span><br><span class="line">gl.vertexAttribPointer(<span class="number">2</span>, <span class="number">5</span>, gl.UNSIGNED_BYTE, <span class="literal">true</span>, <span class="number">5</span>*<span class="number">4</span>, <span class="number">4</span>*<span class="number">4</span>); 😄😄😄</span><br></pre></td></tr></table></figure>
<p>解释上面的句子就是 ==&gt; 我是以 无符号字节(unsigned byte) 传递 并给我传递这些数据归一化, 而且我的尺寸是4 那就说明你要给我传递的这个数字给我分割成 4个数字.</p>
<p>好我们就执行这行代码.<br>在传递给 GUP 的时候他到底做了啥, 我这个做一个 伪代码 模拟一下.<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">传递给 GPU 11111111 00000000 11111111 00000000 ===&gt; 对应的十进制是 255 0 255 0</span><br><span class="line"></span><br><span class="line">我开始分割 因为你的尺寸是 4, 从低位开始切割</span><br><span class="line"></span><br><span class="line">输出 ===&gt; [00000000, 11111111, 00000000, 11111111] ===&gt; [0, 255, 0, 255];</span><br><span class="line"></span><br><span class="line">但是这个数据的返回 不是着色器要 的 范围, 归一化</span><br><span class="line"></span><br><span class="line">因为你的数据类型是 无符号字节(unsigned byte) 它的范围是 0 ~ 255, Nice.</span><br><span class="line"></span><br><span class="line">[0, 255, 0, 255] / 255 ===&gt; [0,1,0,1]</span><br></pre></td></tr></table></figure></p>
<h2 id="传递给着色器"><a href="#传递给着色器" class="headerlink" title="传递给着色器"></a>传递给着色器</h2><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">attribute vec4 a_tint; 😄😄😄</span><br></pre></td></tr></table></figure>
<p>这个里 上一步输出的 数据类型简直就是<br><img src="/posts/af81a0c5/39532F4A.jpg"></p>
<h1 id="学习链接"><a href="#学习链接" class="headerlink" title="学习链接"></a>学习链接</h1><p>这个里我给 能有幸看到这片文章的人 推送几个比较有价值的 学习网站吧. 这些都写的不错.</p>
<p><a href="https://developer.mozilla.org/zh-CN/docs/Web/API/WebGL_API">WebGL(MDN)中文版</a></p>
<p>如果你感觉上面那个([WebGL(MDN)中文版)比较的简单,你可以浏览这个教程网站写的也很不错.</p>
<p><a href="https://webglfundamentals.org/webgl/lessons/zh_cn/">WebGL入门教程</a><br><a href="https://webgl2fundamentals.org/webgl/lessons/zh_cn/">WebGL2教程</a></p>
<p>但是要注意这个都是入门教程,这个东西不足以支撑你写高效率的框架.</p>
<p>实践出真知,只有多磨多练才是硬道理.</p>
<p>有问题 QQ 讨论.</p>
<p>ヾ(￣▽￣)Bye~Bye~<br><!-- # Youtobe 码农
<div class="video-container"><iframe src="//www.youtube.com/embed/l9nh1l8ZIJQ" frameborder="0" allowfullscreen></iframe></div> –&gt;</p>

            <div class="post-copyright">
    <div class="content">
        <p>最后更新： 2019年08月14日 11:22</p>
        <p>原始链接： <a class="post-url" href="/posts/af81a0c5/" title="WebGL以无符号字节传递颜色的原理">https://leng521.top/posts/af81a0c5/</a></p>
        <footer>
            <a href="https://leng521.top">
                <img src="/head.jpg" alt="小魏">
                小魏
            </a>
        </footer>
    </div>
</div>

      
        
            

        
    </div>
    <footer class="article-footer">
        
        
<div class="post-share">
    <a href="javascript:;" id="share-sub" class="post-share-fab">
        <i class="fa fa-share-alt"></i>
    </a>
    <div class="post-share-list" id="share-list">
        <ul class="share-icons">
          <li>
            <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://leng521.top/posts/af81a0c5/&title=《WebGL以无符号字节传递颜色的原理》 — 小魏的博客&pic=https://leng521.tophead.jpg" data-title="微博">
              <i class="fa fa-weibo"></i>
            </a>
          </li>
          <li>
            <a class="weixin share-sns" id="wxFab" href="javascript:;" data-title="微信">
              <i class="fa fa-weixin"></i>
            </a>
          </li>
          <li>
            <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://leng521.top/posts/af81a0c5/&title=《WebGL以无符号字节传递颜色的原理》 — 小魏的博客&source=这个算属于 WebGL 进阶吧, 因为这个属于优化, 运行效率, 如果你不了解 WebGL 的基本知识,你可以到这里先学习基础知识.我会在下面放上几个比较..." data-title="QQ">
              <i class="fa fa-qq"></i>
            </a>
          </li>
          <li>
            <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://leng521.top/posts/af81a0c5/" data-title="Facebook">
              <i class="fa fa-facebook"></i>
            </a>
          </li>
          <li>
            <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《WebGL以无符号字节传递颜色的原理》 — 小魏的博客&url=https://leng521.top/posts/af81a0c5/&via=https://leng521.top" data-title="Twitter">
              <i class="fa fa-twitter"></i>
            </a>
          </li>
          <li>
            <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://leng521.top/posts/af81a0c5/" data-title="Google+">
              <i class="fa fa-google-plus"></i>
            </a>
          </li>
        </ul>
     </div>
</div>
<div class="post-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;" id="wxShare-close">×</a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>

<div class="mask"></div>

        
        <ul class="article-footer-menu">
            
            
  <li class="article-footer-tags">
    <i class="fa fa-tags"></i>
      
    <a href="/tags/js/" class="color3">js</a>
      
    <a href="/tags/WebGL/" class="color1">WebGL</a>
      
    <a href="/tags/前端/" class="color3">前端</a>
      
  </li>

        </ul>
        
    </footer>
  </div>
</article>


    <aside class="post-toc-pos post-toc-top" id="post-toc">
        <nav class="post-toc-wrap">
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#意图"><span class="post-toc-text">意图</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#解决疑惑"><span class="post-toc-text">解决疑惑</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#那一堆位运算到底做了啥"><span class="post-toc-text">那一堆位运算到底做了啥</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#有Uint32Array-处理一下我的数据"><span class="post-toc-text">有Uint32Array 处理一下我的数据</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#指定这些数据怎么用"><span class="post-toc-text">指定这些数据怎么用</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#传递给着色器"><span class="post-toc-text">传递给着色器</span></a></li></ol></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#学习链接"><span class="post-toc-text">学习链接</span></a></li></ol>
        </nav>
    </aside>
    

<nav id="article-nav">
  
    <a href="/posts/ea56194d/" id="article-nav-newer" class="article-nav-link-wrap">

      <span class="article-nav-title">
        <i class="fa fa-hand-o-left" aria-hidden="true"></i>
        
          集成bgfx开源的渲染器
        
      </span>
    </a>
  
  
    <a href="/posts/6512ee5/" id="article-nav-older" class="article-nav-link-wrap">
      <span class="article-nav-title">微信小游戏上传媒体文件</span>
      <i class="fa fa-hand-o-right" aria-hidden="true"></i>
    </a>
  
</nav>



    
        <!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="MTAyMC8zNDA0MC8xMDU3OA==">
<script type="text/javascript">
   (function(d, s) {
       var j, e = d.getElementsByTagName(s)[0];

       if (typeof LivereTower === 'function') { return; }

       j = d.createElement(s);
       j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
       j.async = true;

       e.parentNode.insertBefore(j, e);
   })(document, 'script');
</script>
<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
<!-- City版安装代码已完成 -->
    
</section>
        
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info" class="inner">
      
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


      <p>
        Powered by  <a href="http://hexo.io/" target="_blank">Hexo</a>
        Theme <a href="//github.com/wongminho/hexo-theme-miho" target="_blank">MiHo</a>
      &copy; 2019 小魏<br>
      </p>
    </div>
  </div>
</footer>
    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
  var mihoConfig = {
      root: "https://leng521.top",
      animate: true,
      isHome: false,
      share: true,
      reward: 0
  }
</script>
<div class="sidebar">
    <div id="sidebar-search" title="Search">
        <i class="fa fa-search"></i>
    </div>
    <div id="sidebar-category" title="Categories">
        <i class="fa fa-book"></i>
    </div>
    <div id="sidebar-tag" title="Tags">
        <i class="fa fa-tags"></i>
    </div>
    <div id="sidebar-top">
        <span class="sidebar-top-icon"><i class="fa fa-angle-up"></i></span>
    </div>
</div>
<div class="sidebar-menu-box" id="sidebar-menu-box">
    <div class="sidebar-menu-box-container">
        <div id="sidebar-menu-box-categories">
            <a class="category-link" href="/categories/Cocos-Creator/">Cocos Creator</a><a class="category-link" href="/categories/QQ玩一玩/">QQ玩一玩</a><a class="category-link" href="/categories/cocos2d-x/">cocos2d-x</a><a class="category-link" href="/categories/cocos2dx/">cocos2dx</a><a class="category-link" href="/categories/git/">git</a><a class="category-link" href="/categories/hexo/">hexo</a><a class="category-link" href="/categories/js/">js</a><a class="category-link" href="/categories/linux/">linux</a><a class="category-link" href="/categories/python/">python</a><a class="category-link" href="/categories/前端/">前端</a><a class="category-link" href="/categories/前端/WebGL/">WebGL</a><a class="category-link" href="/categories/前端/bgfx/">bgfx</a><a class="category-link" href="/categories/后端/">后端</a><a class="category-link" href="/categories/后端/golang/">golang</a><a class="category-link" href="/categories/后端/golang/protobuf/">protobuf</a><a class="category-link" href="/categories/后端/nodejs/">nodejs</a><a class="category-link" href="/categories/微信小游戏/">微信小游戏</a><a class="category-link" href="/categories/插件/">插件</a><a class="category-link" href="/categories/自动构建工具/">自动构建工具</a>
        </div>
        <div id="sidebar-menu-box-tags">
            <a href="/tags/9宫格/" style="font-size: 10px;">9宫格</a> <a href="/tags/Cocos-Creator/" style="font-size: 20px;">Cocos Creator</a> <a href="/tags/IT/" style="font-size: 10px;">IT</a> <a href="/tags/QQ玩一玩/" style="font-size: 10px;">QQ玩一玩</a> <a href="/tags/TweenLite/" style="font-size: 10px;">TweenLite</a> <a href="/tags/WebGL/" style="font-size: 10px;">WebGL</a> <a href="/tags/android-studio/" style="font-size: 10px;">android studio</a> <a href="/tags/bgfx/" style="font-size: 12.5px;">bgfx</a> <a href="/tags/c/" style="font-size: 12.5px;">c++</a> <a href="/tags/cocos2d-x/" style="font-size: 15px;">cocos2d-x</a> <a href="/tags/cpp/" style="font-size: 12.5px;">cpp</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/git-扩展工具/" style="font-size: 10px;">git 扩展工具</a> <a href="/tags/github-page/" style="font-size: 10px;">github page</a> <a href="/tags/git命令/" style="font-size: 10px;">git命令</a> <a href="/tags/golang/" style="font-size: 15px;">golang</a> <a href="/tags/hello-world/" style="font-size: 10px;">hello world</a> <a href="/tags/hexo/" style="font-size: 12.5px;">hexo</a> <a href="/tags/js/" style="font-size: 12.5px;">js</a> <a href="/tags/lua/" style="font-size: 12.5px;">lua</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/optionParser/" style="font-size: 10px;">optionParser</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/python/" style="font-size: 17.5px;">python</a> <a href="/tags/scons/" style="font-size: 12.5px;">scons</a> <a href="/tags/spine/" style="font-size: 10px;">spine</a> <a href="/tags/sublime插件/" style="font-size: 10px;">sublime插件</a> <a href="/tags/websocket/" style="font-size: 10px;">websocket</a> <a href="/tags/xmake/" style="font-size: 12.5px;">xmake</a> <a href="/tags/优化/" style="font-size: 12.5px;">优化</a> <a href="/tags/前端/" style="font-size: 15px;">前端</a> <a href="/tags/博客/" style="font-size: 10px;">博客</a> <a href="/tags/原型链/" style="font-size: 10px;">原型链</a> <a href="/tags/后端/" style="font-size: 10px;">后端</a> <a href="/tags/广告/" style="font-size: 10px;">广告</a> <a href="/tags/微信小游戏/" style="font-size: 20px;">微信小游戏</a> <a href="/tags/缺少dll/" style="font-size: 10px;">缺少dll</a> <a href="/tags/闭包/" style="font-size: 10px;">闭包</a>
        </div>
    </div>
    <a href="javascript:;" class="sidebar-menu-box-close">&times;</a>
</div>
<div class="mobile-header-menu-nav" id="mobile-header-menu-nav">
    <div class="mobile-header-menu-container">
        <span class="title">Menus</span>
        <ul class="mobile-header-menu-navbar">
            
            <li>
                <a  href="/">
                    <i class="fa fa-home"></i><span>Home</span>
                </a>
            </li>
            
            <li>
                <a  href="/archives">
                    <i class="fa fa-archive"></i><span>Archives</span>
                </a>
            </li>
            
            <li>
                <a  href="/about">
                    <i class="fa fa-user"></i><span>About</span>
                </a>
            </li>
            
        </ul>
    </div>
    <div class="mobile-header-tag-container">
        <span class="title">Tags</span>
        <div id="mobile-header-container-tags">
            <a href="/tags/9宫格/" style="font-size: 10px;">9宫格</a> <a href="/tags/Cocos-Creator/" style="font-size: 20px;">Cocos Creator</a> <a href="/tags/IT/" style="font-size: 10px;">IT</a> <a href="/tags/QQ玩一玩/" style="font-size: 10px;">QQ玩一玩</a> <a href="/tags/TweenLite/" style="font-size: 10px;">TweenLite</a> <a href="/tags/WebGL/" style="font-size: 10px;">WebGL</a> <a href="/tags/android-studio/" style="font-size: 10px;">android studio</a> <a href="/tags/bgfx/" style="font-size: 12.5px;">bgfx</a> <a href="/tags/c/" style="font-size: 12.5px;">c++</a> <a href="/tags/cocos2d-x/" style="font-size: 15px;">cocos2d-x</a> <a href="/tags/cpp/" style="font-size: 12.5px;">cpp</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/git-扩展工具/" style="font-size: 10px;">git 扩展工具</a> <a href="/tags/github-page/" style="font-size: 10px;">github page</a> <a href="/tags/git命令/" style="font-size: 10px;">git命令</a> <a href="/tags/golang/" style="font-size: 15px;">golang</a> <a href="/tags/hello-world/" style="font-size: 10px;">hello world</a> <a href="/tags/hexo/" style="font-size: 12.5px;">hexo</a> <a href="/tags/js/" style="font-size: 12.5px;">js</a> <a href="/tags/lua/" style="font-size: 12.5px;">lua</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/optionParser/" style="font-size: 10px;">optionParser</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/python/" style="font-size: 17.5px;">python</a> <a href="/tags/scons/" style="font-size: 12.5px;">scons</a> <a href="/tags/spine/" style="font-size: 10px;">spine</a> <a href="/tags/sublime插件/" style="font-size: 10px;">sublime插件</a> <a href="/tags/websocket/" style="font-size: 10px;">websocket</a> <a href="/tags/xmake/" style="font-size: 12.5px;">xmake</a> <a href="/tags/优化/" style="font-size: 12.5px;">优化</a> <a href="/tags/前端/" style="font-size: 15px;">前端</a> <a href="/tags/博客/" style="font-size: 10px;">博客</a> <a href="/tags/原型链/" style="font-size: 10px;">原型链</a> <a href="/tags/后端/" style="font-size: 10px;">后端</a> <a href="/tags/广告/" style="font-size: 10px;">广告</a> <a href="/tags/微信小游戏/" style="font-size: 20px;">微信小游戏</a> <a href="/tags/缺少dll/" style="font-size: 10px;">缺少dll</a> <a href="/tags/闭包/" style="font-size: 10px;">闭包</a>
        </div>
    </div>
</div>
<div class="search-wrap">
    <span class="search-close">&times;</span>
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
            <i class="icon icon-lg icon-chevron-left"></i>
        </a>
        <input class="search-field" placeholder="Search..." id="keywords">
        <a id="search-submit" href="javascript:;">
            <i class="fa fa-search"></i>
        </a>
    <div class="search-container" id="search-container">
        <ul class="search-result" id="search-result">
        </ul>
    </div>
</div>

<div id="search-tpl">
    <li class="search-result-item">
        <a href="{url}" class="search-item-li">
            <span class="search-item-li-title" title="{title}">{title}</span>
        </a>
    </li>
</div>
<script src="/js/search.js"></script>
<script src="/js/main.js"></script>


  <script src="//cdn.bootcss.com/particles.js/2.0.0/particles.min.js"></script>
  <div id="particles"></div>
  <script src="/js/particles.js"></script>







  <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  <script src="//cdn.bootcss.com/scrollReveal.js/3.0.5/scrollreveal.js"></script>
  <script src="/js/animate.js"></script>


  <script src="/js/pop-img.js"></script>
  <script>
     $(".article-entry p img").popImg();
  </script>

  </div>
</body>
</html>